//
//  UIView+Addition.m
//  004-小画板
//
//  Created by HaoYoson on 16/7/13.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "UIView+Addition.h"

@implementation UIView (Addition)

#pragma mark - 截取屏幕视图的方法
- (UIImage *)snapshotImage {
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0);
    [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:NO];
    // 能够关闭之后，取结果！
    UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    // 一定要先关闭，再返回
    return result;
}
#pragma mark - 设置圆角和透明度的方法
- (void)setCornerRadius:(CGFloat)radius alpha:(CGFloat)alphaNum
{
    self.layer.cornerRadius = radius;
    self.layer.masksToBounds = YES;
    self.alpha = alphaNum;
}

#pragma mark - 创建背景颜色透明,内容不透明的控件
- (void)setColorAlpha:(CGFloat)colorAlpha
{
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:colorAlpha];
}


@end
